package com.ttwl.www.app.meFrame.myCourseFrame;

import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.Toast;

import com.ttwl.www.app.R;

public class MyCourseActivity extends AppCompatActivity {
    private ImageView goBack;
    private RadioGroup phTab;
    private RecyclerView courseList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_course);
        goBack = (ImageView) findViewById(R.id.go_back);
        goBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        courseList = (RecyclerView) findViewById(R.id.course_list);
        courseList.setLayoutManager(new LinearLayoutManager(MyCourseActivity.this));
        courseList.addItemDecoration(new MyDecoration());
        courseList.setAdapter(new LinearAdapterCourse(MyCourseActivity.this));

        phTab = (RadioGroup) findViewById(R.id.mc_tab_bar);
        phTab.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                switch (checkedId) {
                    case R.id.mc_all:
                        Toast.makeText(MyCourseActivity.this,"所有课程~",Toast.LENGTH_SHORT).show();
                        break;
                    case R.id.mc_pay:
                        Toast.makeText(MyCourseActivity.this,"付费课程~",Toast.LENGTH_SHORT).show();
                        break;
                    case R.id.mc_expired:
                        Toast.makeText(MyCourseActivity.this,"过期课程~",Toast.LENGTH_SHORT).show();
                        break;
                }
            }
        });

    }

    class MyDecoration extends RecyclerView.ItemDecoration {
        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            super.getItemOffsets(outRect, view, parent, state);
            outRect.set(0,0,0,getResources().getDimensionPixelOffset(R.dimen.dividerHeight));
        }
    }
}
